﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Rock
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void lblPlayer_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
        private int playerWin = 0;
        private int computerWin = 0;
        //游戏调用
        private void Play(string fistStr)
        {
            //玩家出石头
            lblPlayer.Text = fistStr;
            var play = new Player();
            var enumPlayer = play.ShowFist(fistStr);

            //电脑出拳
            var com = new Computer();
            var enumCom = com.ShowFist();
            lblComputer.Text = com.Fist.ToString();

            //裁判出场
            var enumResult = Judge.GetResult((int)enumPlayer, (int)enumCom);
            lblResult.Text = enumResult.ToString();
            //统计输赢次数
            if (enumResult == EnumResult.玩家赢)
            { 
                playerWin++;
                lblPlayerWin.Text = playerWin.ToString();
            }
            else if (enumResult == EnumResult.电脑赢)
            {
                computerWin++;
                lblComputerWin.Text = computerWin.ToString();
            }
        }
        private void btRock_Click(object sender, EventArgs e)
        {
            string fistStr = "石头";
            Play(fistStr);
        }

        private void btScissors_Click(object sender, EventArgs e)
        {
            string fistStr = "剪刀";
            Play(fistStr);
        }

        private void btnPaper_Click(object sender, EventArgs e)
        {
            string fistStr = "布";
            Play(fistStr);
        }
    }
}
